import 'package:dio/dio.dart';
import 'package:incidentmanager/common/config/constant.dart';
import 'package:incidentmanager/common/data/network/interceptors/data_interceptor.dart';
import 'package:incidentmanager/common/data/network/interceptors/loading_interceptor.dart';
import 'package:incidentmanager/common/data/network/interceptors/token_interceptor.dart';

class Http {
  Http._();

  static Dio _http;

  static Dio getInstance() {
    if (_http != null) {
      return _http;
    }
    var dio = Dio(
      BaseOptions(
          baseUrl: BASE_URL, connectTimeout: 5000, receiveTimeout: 5000),
    );
    dio.interceptors
      ..add(TokenInterceptors())
      ..add(LoadingInterceptors())
      ..add(DataInterceptors())
      ..add(LogInterceptor());
    _http = dio;
    return _http;
  }
}
